#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cctype>
#include "Edinburgh_Angio/myangio.h"
using namespace std;

#include "ImprovedMath.h"
#include "EasyBMP.h"
#include "Matrix.h"

extern int Xnodes;
extern int Ynodes;

extern Matrix Phi;
extern Matrix PhiQuiescent;
extern Matrix PhiNecrotic;
extern Matrix Mobility;
extern Matrix BloodVesselIndicator;

extern double _EPS;

extern double MaxMobility;
extern double MinimumMobility;
extern double MaximumMobility;

extern Matrix SproutTips;
extern Matrix BloodVesselIndicator;

bool QuickPlot( void )
{
 BMP Output;
 Output.SetSize( Xnodes, Ynodes );
 
 RGBApixel Proliferating;
 Proliferating.Red = 255;
 Proliferating.Green = 0;
 Proliferating.Blue  = 0;

 RGBApixel Quiescent;
 Quiescent.Red = 0;
 Quiescent.Green = 0;
 Quiescent.Blue  = 255;
 
 RGBApixel Necrotic;
 Necrotic.Red = 155;
 Necrotic.Green = 74;
 Necrotic.Blue  = 18;

 int i,j;
 for( j=0 ; j < Ynodes ; j++ )
 {
  for( i=0 ; i < Xnodes ; i++ )
  {
   bool Done = false;
   
   RGBApixel TempColor;
   TempColor.Red = 255;
   TempColor.Green = 255;
   TempColor.Blue = 255;
   
   if( *PhiNecrotic(i,j) < _EPS )
   { TempColor = Necrotic; Done = true; }
   if( *PhiQuiescent(i,j) < _EPS && !Done )
   { TempColor = Quiescent; Done = true; }
   if( *Phi(i,j) < _EPS && !Done )
   { TempColor = Proliferating; Done = true; }

   if( *BloodVesselIndicator(i,j) > 0.5 )
   {
    TempColor.Red = 0;
	TempColor.Blue = 0;
	TempColor.Green = 0;
   }
 /**  
   if( *SproutTips(i,j) > 0.5 )
   { 
    TempColor.Red = 0;
	TempColor.Green = 192;
	TempColor.Blue = 0;
   }
   **/
   *Output(i,Ynodes-j-1) = TempColor;
  }
 }
 
 Output.WriteToFile( "Snapshot.bmp" ); 
 return true;
}

